package utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

public class YaPreferences {
	
	public YaPreferences(Context app){
		ctx = app;
		yaPrefs = ctx.getSharedPreferences(PREFS_NAME, Activity.MODE_PRIVATE);
		
//		SharedPreferences.Editor yaEdit = yaPrefs.edit();
//		yaEdit.putString("token", "");
	}
	
	public boolean hasToken() {
		Log.d("yandex",yaPrefs.getString("token", ""));
		if(yaPrefs.getString("token", "").equals("")){
			return false;
		}
		return true;
	}
	
	public String getToken() {
		return yaPrefs.getString("token","");
	}
	
	public void setToken(String token) {
		SharedPreferences.Editor yaEdit = yaPrefs.edit();
		yaEdit.putString("token", token);
		yaEdit.commit();
	}
	
	
	private Context ctx;
	private SharedPreferences yaPrefs;
	public final static String PREFS_NAME = "YaPrefs";
}
